home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13881 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  53 lines

  1. Path: ub239.dialup.uwa.edu.au!localhost!prye
  2. From: prye@cyllene.uwa.edu.au (Peter Rye)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help:what is wrong this code?
  5. Date: 10 Apr 1996 15:12:19 GMT
  6. Organization: The University of Western Australia
  7. Message-ID: <PRYE.96Apr10231219@cyllene.uwa.edu.au>
  8. References: <4k3p3q$n76@brahms.udel.edu> <4k4hi3$5hm@sparcserver.lrz-muenchen.de>
  9.     <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>
  10. NNTP-Posting-Host: ub239.dialup.uwa.edu.au
  11. In-reply-to: Norma Mathews's message of Tue, 9 Apr 1996 21:05:47 -0700
  12. X-Mailer: GNU Emacs 19.28
  13.  
  14. >>>>> "Norma" == Norma Mathews <n9341884@henson.cc.wwu.edu> writes:
  15.  
  16.     Norma> On 6 Apr 1996, Kurt Watzka wrote:
  17.  
  18.     >> yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
  19.     >> 
  20.     >> 
  21.     >> >Why it give me 0.0000?
  22.     >> 
  23.     >> >#include <stdio.h> >main () { >double a=9.008;
  24.     >> >printf("%f\n",sqrt(a)); >return 0; >}
  25.  
  26.  
  27.  
  28.  
  29.     Norma> your printf specifer needs to be "%lf", not "%f", since a
  30.     Norma> is a double
  31.  
  32. But when I try this my compiler complains:
  33.  
  34. ub239:~$ cat junk.c
  35. #include <math.h>
  36. #include <stdio.h>
  37.  
  38. int main() {
  39.   double x = 3.232;
  40.   printf("%lf\n", sqrt(x));
  41.   return 0;
  42. }
  43. ub239:~$ gcc -c -Wall -ansi -pedantic junk.c
  44. junk.c: In function `main':
  45. junk.c:6: warning: use of `l' length character with `f' type character
  46.  
  47. Why ?  ;-)
  48. --
  49. Peter Rye   prye@cyllene.uwa.edu.au,  prye@ichr.uwa.edu.au
  50. Respiratory Research Fellow, Princess Margaret Hospital for Children
  51. Perth, Western Australia    Ph: +61 (09) 340 8985, Fax: +61 (09) 388 2097
  52. ** Smoking areas in restaurants are like peeing areas in swimming pools. **
  53.